package cn.jeeweb.modules.client.service.impl;

import cn.jeeweb.core.common.service.impl.CommonServiceImpl;
import cn.jeeweb.core.query.data.Page;
import cn.jeeweb.core.query.data.PageImpl;
import cn.jeeweb.core.query.data.Pageable;
import cn.jeeweb.core.query.data.Queryable;
import cn.jeeweb.modules.client.entity.Bale;
import cn.jeeweb.modules.client.entity.ClientOrder;
import cn.jeeweb.modules.client.mapper.BaleMapper;
import cn.jeeweb.modules.client.service.IBaleService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**   
 * @Title: 打包
 * @Description: 打包
 * @author zhuht
 * @date 2018-08-26 23:47:42
 * @version V1.0   
 *
 */
@Transactional
@Service("baleService")
public class BaleServiceImpl  extends CommonServiceImpl<BaleMapper,Bale> implements IBaleService {

    public Page<Map> selectBalePage(Queryable queryable){
        Pageable pageable = queryable.getPageable();
        com.baomidou.mybatisplus.plugins.Page<Map> page = new com.baomidou.mybatisplus.plugins.Page<Map>(
                pageable.getPageNumber(), pageable.getPageSize());
        String createDate = (String) queryable.getValue("createDate");
        if(createDate==null||"".equals(createDate)){
            createDate = (new java.text.SimpleDateFormat("yyyy-MM-dd")).format(new Date());
        }
        page.setRecords(baseMapper.selectBalePage(page, createDate));
        com.baomidou.mybatisplus.plugins.Page<Map> content = page;
        return new PageImpl<Map>(content.getRecords(), queryable.getPageable(), content.getTotal());
    }

    public List<Map> selectBaleAll(String createDate,String page,String size){
        return baseMapper.selectBaleAll(createDate,page,size);
    }

    public List<Map> selectOrderList(String order){
        return baseMapper.selectOrderList(order);
    }
    public List<Map> selectOrderByBaleState(String createDate,String createDateEnd){
        if(createDate==null||"".equals(createDate)){
            createDate = (new java.text.SimpleDateFormat("yyyy-MM-dd")).format(new Date());
        }
        if(createDateEnd==null||"".equals(createDateEnd)){
            createDateEnd = (new java.text.SimpleDateFormat("yyyy-MM-dd")).format(new Date());
        }
        return baseMapper.selectOrderByBaleState(createDate,createDateEnd);
    }
}
